<!--数据字典管理-->
<template>
  <a-modal v-model="showAddTable" :mask-closable="false" :closable="false" :width="800"
           title="教师不排课规则"
           :maskClosable="false"
           :destroyOnClose="true">
      <a-table style="height: 600px;overflow-y: auto" :columns="columns" :dataSource="teacherSelectList" :rowKey="record => record.value"
               :pagination="false">
                <span slot="index" slot-scope="text, record, index">
                    {{ (page.currentPage - 1) * page.pageSize + index + 1 }}
                </span>
        <span slot="operation" slot-scope="text, record, index" class="table-operation">
          <a @click="setNotSchedule(record)">
                            设置不排课时间</a>
            <a @click="showNotSchedule(record)">
                            查看不排课时间</a>
                </span>
      </a-table>
    <not-schedule ref="teacherNotSchedule" type="1"/>
      <not-schedule-time-list ref="notScheduleTimeList" type="2"/>

  </a-modal>
</template>

<script>
import Util from '@/libs/util';
import notSchedule from './notSchedule.vue';
import notScheduleTimeList from './notScheduleTimeList.vue';


export default {
  name: 'teacherNotScheduleList',
  components: {
    notSchedule,
      notScheduleTimeList
  },
  data() {
    return {
      title: true,
      selectedRowKeys:[],
      showAddTable: false,
      classTId: '',
      page: {
        currentPage: 1,
        pageSize: 10
      },
      columns: [
        {title: '序号', key: 'index', width: '15%', align: 'center', scopedSlots: {customRender: 'index'}},
        {title: '教师', dataIndex: 'label', key: 'label'},
        {title: '操作', key: 'operation', scopedSlots: {customRender: 'operation'}}
      ],
    }
  },
  computed: {
    teacherSelectList() {
      return this.$store.state.courseManage.teacherSelectList
    },

  },
  filters: {
    filterWord(value, list) {
      for (let i = 0; i < list.length; i++) {
        if (value === list[i].value) {
          return list[i].label
        }
      }
    },
  },
  methods: {

    /**
     * Function    : saveApply
     * Description : 角色信息新增、编辑保存
     * Input       : name
     * Return      : none
     */
    saveApply() {
      let _this = this

      let para = {}
      para.courseId = _this.courseId
      para.classIdList = _this.selectedRowKeys
      this.$store.dispatch('saveCourseScheduleClassAct', para).then(response => {
        this.showAddTable = false
        if (response.code === 0) {
          this.$emit('init')
          this.$message.success(response.message)
        } else {
          this.$message.error(response.message)
        }
      })
    },

    /**
     * Function    : cancelApply
     * Description : 取消弹出框
     * Input       : val
     * Return      : none
     */
    cancelApply() {
      this.showAddTable = false
      this.selectedRowKeys = []
    },

    /**
     * Function    : onSelectChange
     * Description : 选择当前行id
     * Input       : none
     * Return      : none
     */
    onSelectChange (selectedRowKeys) {
      this.selectedRowKeys = selectedRowKeys
    },

    showModal () {
      this.showAddTable = true
      this.init()
    },
      setNotSchedule (record) {
          this.$refs.teacherNotSchedule.showModal(record.value)
      },
      showNotSchedule (record) {
          this.$refs.notScheduleTimeList.showModal(record.value,'teacher')
      },

    emitEmpty() {
      this.searchKey = ''
      this.init()
    },
    reStore() {
      this.init();
    },

    clearDTO() {
      this.objDTO = {
        recordId: '',
        name: '',
        buildName: '',
        buildCode: '',
        roomCode: '0',
        diskNum: '',
      }
    },
    /*
     * 过滤输入框输入的特殊字符
     * */
    formatEnterContent(value) {
      let a = Util.clearSpecialChart(value);
      this.searchKey = a
    },
    /**
     * Function    : init
     * Description : 初始化列表
     * Input       : none
     * Return      : none
     */
    init() {
      let _this = this;
      this.selectedRowKeys = []
      let para = Object.assign({},
          {courseId: this.courseId})
      this.$store.dispatch('getTeacherSelectListAct', para)
    },



  },
  created() {
    this.searchKey = this.$route.query.searchKey === undefined ? '' : this.$route.query.searchKey
    this.page.currentPage = this.$route.query.currentPage === undefined ? 1 : this.$route.query.currentPage
    this.page.pageSize = this.$route.query.pageSize === undefined ? 10 : this.$route.query.pageSize
    // this.init()
  },
  mounted() {

  }
}
</script>
